package com.qf.application.controller;


import com.qf.application.entity.Lender;
import com.qf.application.service.LenderService;
import com.qf.application.utils.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author l
 * @since 2024-07-07
 */
@RestController
@RequestMapping("/lender")
public class LenderController {

    @Autowired
    private LenderService lenderService;

    @PostMapping("save")
    public Result loan(@RequestBody Lender lender){
        lender.setLenderDate(new Date());
        boolean save = lenderService.save(lender);
        return Result.success(save,"借款成功");
    }

    @PutMapping("update")
    public Result putLenderDateByUserId(String repaymentTerm, Long userId){
        Boolean b = lenderService.putLenderDateByUserId(repaymentTerm, userId);
        return Result.success(b,"更新期限成功");
    }

}
